#region OpenNETCF Copyright Information
/*
Copyright (c) 2007 OpenNETCF Consulting, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of this software 
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial 
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#endregion

using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Text;

namespace OpenNETCF.WindowsMobile.Ink.Interfaces
{
    [
        Guid("9D398FA0-C4E2-4FCD-9973-975CAAF47EA6"),
        ComImport,
        InterfaceType(ComInterfaceType.InterfaceIsDual)
    ]
    public interface IInkDisp
    {
        IInkStrokes Strokes { get; }
        
        IInkExtendedProperties ExtendedProperties { get; }

        bool Dirty { get; set; }
        
        IInkCustomStrokes CustomStrokes { get; }
        
        IInkRectangle GetBoundingBox(InkBoundingBoxMode BoundingBoxMode);
        
        [PreserveSig]
        int DeleteStrokes(IInkStrokes Strokes);
        
        [PreserveSig]
        int DeleteStroke(IInkStrokeDisp Stroke);
        
        [PreserveSig]
        int ExtractStrokes(IInkStrokes Strokes, InkExtractFlags ExtractFlags, out IInkDisp strokes);
        
        [PreserveSig]
        int Clip(IInkRectangle Rectangle);
        
        [PreserveSig]
        int Clone(out IInkDisp val);
        
        [PreserveSig]
        int HitTestCircle(int x, int y, [MarshalAs(UnmanagedType.R4)]float radius, out IInkStrokes strokes);
        
        [PreserveSig]
        int HitTestWithRectangle(IInkRectangle SelectionRectangle, [MarshalAs(UnmanagedType.R4)]float IntersectPercent, out IInkStrokes strokes);

        [PreserveSig]
        int HitTestWithLasso(object Points, [MarshalAs(UnmanagedType.R4)]float IntersectPercent, object LassoPoints, out IInkStrokes strokes);
        
        [PreserveSig]
        int CreateStrokes([MarshalAs(UnmanagedType.SafeArray)]int[] StrokeIds, out IInkStrokes strokes);
        
        [PreserveSig]
        int AddStrokesAtRectangle(IInkStrokes SourceStrokes, IInkRectangle TargetRectangle);
        
        object Save(InkPersistenceFormat PersistenceFormat, InkPersistenceCompressionMode CompressionMode);

        [PreserveSig]
        int Load(object data);

        IInkStrokeDisp CreateStroke(object PacketData, object PacketDescription);
        
        /*IDataObject*/
        object ClipboardCopy(IInkStrokes Strokes, InkClipboardFormats ClipboardFormats, InkClipboardModes ClipboardModes);

        bool CanPaste(/*IDataObject*/ object DataObject);

        IInkStrokes ClipboardPaste(int x, int y, /*IDataObject*/ object DataObject);
    }

    [
        Guid("9D398FA0-C4E2-4FCD-9973-975CAAF47EA6"),
        ComImport,
        InterfaceType(ComInterfaceType.InterfaceIsDual)
    ]
    public interface IInkDisp2
    {
        [DispId(0x00000001)]
        IInkStrokes Strokes { get;}
        [DispId(0x00000002)]
        /*IInkExtendedProperties*/
        object ExtendedProperties { get;}
        [DispId(0x00000008)]
        bool Dirty { get; set;}
        [DispId(0x00000009)]
        /*IInkCustomStrokes*/
        object CustomStrokes { get;}
        [DispId(0x00000003)]
        IInkRectangle GetBoundingBox(InkBoundingBoxMode BoundingBoxMode);
        [DispId(0x00000004)]
        void DeleteStrokes(IInkStrokes Strokes);
        [DispId(0x00000005)]
        void DeleteStroke(/*IInkStrokeDisp*/ object Stroke);
        [DispId(0x00000006)]
        IInkDisp ExtractStrokes(
            IInkStrokes Strokes,
                        InkExtractFlags ExtractFlags);
        [DispId(0x00000007)]
        IInkDisp ExtractWithRectangle(
                        IInkRectangle Rectangle,
                        InkExtractFlags ExtractFlags);
        [DispId(0x00000012)]
        void Clip(IInkRectangle Rectangle);
        [DispId(0x0000000a)]
        IInkDisp Clone();
        [DispId(0x0000000b)]
        IInkStrokes HitTestCircle(
        int x,
        int y,
        [MarshalAs(UnmanagedType.R4)]float radius);
        
        [DispId(0x0000000c)]
        IInkStrokes HitTestWithRectangle(IInkRectangle SelectionRectangle, [MarshalAs(UnmanagedType.R4)]float IntersectPercent);

        [DispId(0x0000000d)]
        IInkStrokes HitTestWithLasso(object Points, [MarshalAs(UnmanagedType.R4)]float IntersectPercent,object LassoPoints);
        
        [DispId(0x0000000e)]
        IInkStrokeDisp NearestPoint(int x, int y, ref float PointOnStroke, ref float DistanceFromPacket);

        [DispId(0x0000000f)]
        IInkStrokes CreateStrokes([MarshalAs(UnmanagedType.SafeArray)]int[] StrokeIds);
        [DispId(0x00000011)]
        void AddStrokesAtRectangle(IInkStrokes SourceStrokes, IInkRectangle TargetRectangle);
        [DispId(0x00000013), PreserveSig]
        //[return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType=VarEnum.VT_UI1)]
        /*byte[]*/
        int Save(
             InkPersistenceFormat PersistenceFormat,
             InkPersistenceCompressionMode CompressionMode, IntPtr pData);

        [DispId(0x00000014)]
        void Load([MarshalAs(UnmanagedType.SafeArray)] byte[] Data);

        [DispId(0x00000010)]
        IInkStrokeDisp CreateStroke(object PacketData, object PacketDescription);
        [DispId(0x00000016)]
        /*IDataObject*/
        object ClipboardCopyWithRectangle(
        IInkRectangle Rectangle,
        InkClipboardFormats ClipboardFormats,
        InkClipboardModes ClipboardModes);
        [DispId(0x00000017)]
        /*IDataObject*/
        object ClipboardCopy(
            IInkStrokes Strokes,
        InkClipboardFormats ClipboardFormats,
        InkClipboardModes ClipboardModes);

        [DispId(0x00000018)]
        bool CanPaste(/*IDataObject*/ object DataObject);

        [DispId(0x00000019)]
        IInkStrokes ClipboardPaste(
        int x,
        int y,
            /*IDataObject*/ object DataObject);
    }

    public class InkDisp
    {
        public static IInkDisp CreateInstance()
        {
            Type t = Type.GetTypeFromCLSID(new Guid("937C1A34-151D-4610-9CA6-A8CC9BDB5D83"));
            return (IInkDisp)Activator.CreateInstance(t);
        }
    }

    [StructLayout(LayoutKind.Sequential)]
    public struct VARIANT
    {
        private ushort vt;
        public short wReserved1;
        public short wReserved2;
        public short wReserved3;
        public int Val1;
        public int Val2;
        public VarEnum Vt
        {
            get { return (VarEnum)vt; }
            set { vt = (ushort)value; }
        }

        [DllImport("oleaut32")]
        public extern static void VariantInit(ref VARIANT v);
        [DllImport("oleaut32")]
        public extern static void VariantClear(ref VARIANT v);
    };

 

}
